/**
 * Created by wangzilong on 2017/4/12.
 */
const test = 'http://test.520m.com.cn/api/';
const project = 'http://www.520m.com.cn/api/';
var serviceUrl = test;

function LoginPost(serviceName, dataObj, call, method) {
    var list = [];
    for(var key in dataObj){
        list.push(key+'='+dataObj[key]);
    }
    var urlMsg =list.join('&');
    var url = serviceUrl + serviceName;
    fetch(url,{
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        body:urlMsg
    })
    .then((response)=>{
        return response.text();
    })
    .then((data)=>{ 
        // alert(data)
        var obj = JSON.parse(data);
        call(obj);
    })
    .catch((error)=>{
        // alert('请检查您的网络问题！')
        alert(JSON.stringify(error))
        console.log('Request Faild', error);
    })
}

module.exports = LoginPost;

